2 <TITLE>Binary tree reorganization hashing: insertion
7 <A HREF="../../images/handbook.gif"><IMG SRC="../../images/handbook2.gif" align=left></A>
8 <A HREF="../../hbook.html">
9 <IMG SRC="../../images/home_g.gif" hspace = 15 vspace = 4></A><BR>
10 <A HREF="../../expand.html">
11 <IMG SRC="../../images/contents_g.gif" hspace = 15 vspace = 4></A><BR>
12 <A HREF="../../search_a.html">
13 <IMG SRC="../../images/chapter_g.gif" hspace = 15 vspace = 4></A><BR>
14 <A HREF="311.ins.c.html"><IMG SRC="../../images/prevalg_g.gif" hspace = 15 vspace = 4></A><BR>
15 <A HREF="311c.srch.c.html">
16 <IMG SRC="../../images/nextalg_g.gif" hspace = 15 vspace = 4></A><BR>
19 <H2><B>Binary tree reorganization hashing: insertion
28 procedure insert( key : typekey; var r : dataarray );
29 var i, inc, init, j : integer;
31 function SearchMove ( init, inc, level : integer ) : integer;
32 {*** Find the first hole (empty location) at the given depth
33 in the binary tree spanned by a key ***}
35 var i, inc1, j, k : integer;
37 i := (init + inc*level) mod m;
38 if empty(r[i]) or deleted(r[i]) then SearchMove := i
40 for j:=level-1 downto 0 do begin
41 i := (init + inc*j) mod m;
42 inc1 := increment( r[i].k );
43 k := SearchMove( (i+inc1) mod m, inc1, level-j-1 );
45 {*** A hole was found, move forward ***}
48 goto 999 {*** return ***}
51 {*** Could not find hole ***}
58 init := hashfunction( key );
59 inc := increment( key );
61 while (i<=n) and (j<0) and (n<m) do begin
62 j := SearchMove( init, inc, i );
66 {*** A hole was found, insert key ***}
70 else Error {*** table is full ***};
72 </XMP></TD></TR></TABLE>
74 <H3><A HREF="ftp://sunsite.dcc.uchile.cl/pub/users/rbaeza/handbook/algs/3/3382.ins.p"><IMG SRC="../../images/ftp.xbm" hspace=10>Pascal</A> source (3382.ins.p) </H3></CENTER>
76 <IMG SRC="../../images/aw3.gif" align=left><H5><BR>
77 © <A HREF="http://aw.com">Addison-Wesley </A>Publishing Co. Inc.